import { request } from "@/utils/service"
import type * as Report from "./types/report"

/** 01. 查 */
export function getReportDataApi(data: Report.ReportSearchData) {
  return request<Report.ReportResponseData>({
    url: "report/list",
    method: "post",
    data
  })
}

/** 02  某日的详情 */
export function dayDetailApi(id: number) {
  return request<ApiResponseData<Report.DayReportData>>({
    url: `/report/day/${id}`,
    method: "get"
  })
}

//
/** 02 -01 某日的详情 */
export function dayDetailByUserIdAndDateApi(userId: number, date: string) {
  return request<ApiResponseData<Report.DayReportData>>({
    url: "/report/day/detail",
    method: "get",
    params: {
      userId,
      date
    }
  })
}

/** 03 删 */
export function deleteReportApi(id: number) {
  return request({
    url: `/report/delete/${id}`,
    method: "post"
  })
}

/** 04 批量新增  */
export function batchInsertApi(data: Report.ReportData[]) {
  return request({
    url: "report/batchInsert",
    method: "post",
    data
  })
}

//  05 更新
export function updateReportApi(data: Report.ReportData) {
  return request<ApiResponseData<boolean>>({
    url: `report/update`,
    method: "post",
    data
  })
}

// 06 根据条件导出
export function exportDataApi(data: Report.ReportSearchData) {
  return request<Report.ReportResponseData>({
    url: "report/export",
    method: "get",
    data
  })
}
